package org.jetlinks.pro.auth.wechat.miniprogram;

import lombok.Getter;
import lombok.Setter;
import org.jetlinks.pro.auth.sso.ThirdPartyProviderSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@ConfigurationProperties(prefix = "sso.wechat")
@Component
@Getter
@Setter
public class WechatProperties implements ThirdPartyProviderSupport {

    //微信小程序登录
    private List<MiniProgramSsoProvider> miniProgram = new ArrayList<>();




    @Autowired
    private WebClient.Builder clientBuilder;

    @PostConstruct
    public void init(){
        for (MiniProgramSsoProvider provider : miniProgram) {
            provider.init(clientBuilder);
        }
    }

    @Override
    public List<MiniProgramSsoProvider> getProviders() {
        return miniProgram;
    }
}
